<?php

require_once('./includes/class/Usefull.class.php');
require_once('./includes/configuration.php');
require_once('./includes/global.php');

function getDbConnection() {
    try {
        $PDO = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
        if (DB_DEBUG) {
            $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
        }
        $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
    } catch (PDOException $e) {
        echo "Connexion &agrave; la base de donn&eacute;es impossible.";
    }
    return $PDO;
}


$Usefull = new Usefull();
$PDO = getDbConnection();

/* Table tb_info - DEBUT */
$info = $PDO->prepare("SELECT * FROM  " . DB_NAME . "." . TB_INFO . "");
$info->execute();
$reqInfo = $info->fetchAll();
foreach ($reqInfo as $data) {
    foreach ($data as $key => $value) {
        switch ($key) {
            case 'site_name':
                $site = $value;
                break;
            case 'site_extension':
                $extension = $value;
                break;
            case 'site_cryptage':
                $cryptage = $value;
                break;
            case 'site_theme':
                $siteTheme = $value;
                break;
            case 'site_date':
                $siteDate = $Usefull->convertDate($value);
                break;
            case 'forum':
                $forum = $value;
                break;
            case 'live':
                $live = $value;
                break;
            case 'youtube':
                $youtube = $value;
                break;
            case 'facebook':
                $facebook = $value;
                break;
            case 'twitter':
                $twitter = $value;
                break;
            case 'google':
                $google = $value;
                break;
            case 'vocal_choice':
                $vocalChoice = $value;
                break;
            case 'vocal_type':
                $vocalType = $value;
            case 'vocal_ip':
                $vocalIp = $value;
                break;
            case 'vocal_port':
                $vocalPort = $value;
                break;
            case 'vocal_password':
                $vocalPassword = $value;
                break;
            case 'server_local':
                $serverLocal = $value;
                break;
            case 'server_ip':
                $serverIp = $value;
                break;
            case 'server_port':
                $serverPort = $value;
                break;
            case 'server_version':
                $serverVersion = $value;
                break;
            case 'server_type':
                $serverType = $value;
                break;
            case 'server_bukkit':
                $serverBukkit = $value;
                break;
            case 'server_date':
                $serverDate = $Usefull->convertDate($value);
                break;
            case 'annonce_choice':
                $annonceChoice = $value;
                break;
            case 'annonce_type':
                $annonceType = $value;
                break;
            case 'annonce_texte':
                $annonceTexte = $value;
                break;
            case 'maintenance_choice':
                $maintenanceChoice = $value;
                break;
            case 'maintenance_texte':
                $maintenanceTexte = $value;
                break;
            default:

                break;
        }
    }
}

$vocalAdresse = $vocalIp . ":" . $vocalPort;
/* Table tb_info - FIN */

/* Table tb_plugins - DEBUT */
$plugin = $PDO->prepare("SELECT * FROM  " . DB_NAME . "." . TB_PLUGINS . "");
$plugin->execute();
$reqPlugin = $plugin->fetchAll();

foreach ($reqPlugin as $data) {
    foreach ($data as $key => $value) {
        switch ($key) {
            case 'dynmap':
                $dynmap = $value;
                break;
            case 'dynmap_url':
                $dynmap_url = $value;
                break;
            case 'minequery':
                $minequery = $value;
                break;
            case 'hawkeye':
                $hawkeye = $value;
                break;
            case 'iconomy':
                $iconomy = $value;
                break;
            case 'jobs':
                $jobs = $value;
                break;
            default:

                break;
        }
    }
}

/* Table tb_plugins - FIN */
?>
